package com.atguigu0.streaming

import org.apache.spark.SparkConf
import org.apache.spark.streaming.dstream.ReceiverInputDStream
import org.apache.spark.streaming.{Seconds, StreamingContext}

/**
 * @description: xxx
 * @time: 2020/6/15 22:47
 * @author: baojinlong
 **/
object CustomerReceiverTest {
  def main(args: Array[String]): Unit = {
    // 创建SparkConf
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("wordCount")
    // 创建SteamingContext
    val ssc = new StreamingContext(sparkConf, Seconds(3))
    // 创建DsStream
    val line: ReceiverInputDStream[String] = ssc.receiverStream(new CustomerReceiver("hadoop102", 8888))
    // 打印数据
    line.print
    //开启
    ssc.start()
    ssc.awaitTermination()
  }
}
